const { expect } = require("chai");
const { ethers } = require("hardhat");

describe("MyNFT", function () {
  let myNFT, owner, addr1;

  beforeEach(async function () {
    [owner, addr1] = await ethers.getSigners();
    const MyNFT = await ethers.getContractFactory("MyNFT");
    myNFT = await MyNFT.deploy();
    await myNFT.waitForDeployment();
  });

  it("部署后 owner 是正确的", async function () {
    expect(await myNFT.owner()).to.equal(owner.address);
  });

  it("只有 owner 可以 mint", async function () {
    await myNFT.mint(addr1.address);
    expect(await myNFT.ownerOf(0)).to.equal(addr1.address);

    await expect(
      myNFT.connect(addr1).mint(addr1.address)
    ).to.be.revertedWith("Ownable: caller is not the owner");
  });
});
